<!-- <?php 
print_r($actions); 
print_r($user);
?> -->
<div id="main_block">
<?php if($action_pending) { ?>
<div class="message_line" id="top_message">
You have actions to perform.
</div>
<?php } ?>
<h1><?php echo $user->name; ?></h1>
<p><?php echo $user->info; ?></p>
<table class="data_table">
<tr>
  <td style="font-weight:bold;">Full name: </td>
  <td><?php echo $user->name; ?></td>
</tr>
<tr>
  <td style="font-weight:bold;">Username: </td>
  <td><?php echo $user->username; ?></td>
</tr>
<tr>
  <td style="font-weight:bold;">Articles written: </td>
  <td><?php echo count($user->articles()); ?></td>
</tr>
</table>
<h1>Your actions</h1>
<?php if(is_array($user->actions()) && (count($user->actions())>0)) {?>
<table class="data_table">
<?php foreach($user->actions() as $action):?>
<tr>
    <td>Autor has responded to your flag!</td>
    <td><?php echo article_title_link($action); ?></td>
    <td><?php echo $action->latest_event->flag_event_type_name; ?><br/><a href="">Flag history</a></td>
    <td><?php foreach($action->next_actions as $next_action): ?>
<button type="button" onclick="actionDlgShow(<?php echo $action->idflag; ?>,<?php echo $next_action->idflag_event_type; ?>,'<?php echo $next_action->action_button_name; ?>' )">
											        <?php echo $next_action->action_button_name; ?></button>
<?php endforeach; ?></td>

</tr>
<?php endforeach; ?> </table> <?php } else { ?>
You have no open actions.
<?php } ?>
<h1>Your articles</h1>
<?php if(is_array($user->articles()) && (count($user->articles())>0)) {?>
<table class="data_table">
<?php foreach($user->articles() as $article):?>
    <tr>
        <td><?php echo article_title_link($article); ?></td>
        <td>Published on: <?php echo $article->timepublished; ?> </td>
        <td>Score:<?php echo $article->score; ?>
        <?php 
        foreach($article->flags() as $flag_overview) 
        { 
            echo '<br/><a href="">!: ' . $flag_overview->flag_type_name . " (" . $flag_overview->idarticles_flag_points . "/" . $flag_overview->treshold . ")</a>";
        }
        ?>
        
        </td>
        <td><input type=button value="Edit" onclick="window.location='<?php echo site_url('write/edit/' . $article->idarticle) ?>'"/></td>
    </tr>
    <?php endforeach; ?></table><?php } else {?>
You have not written any articles. <a href="<?php echo site_url("write"); ?>">Write an article now!</a>
<?php } ?>

<?php /*
<div id="actionDlg">
<h1 id="actionDlgTitle">title</h1>
Response text:
<textarea id="actionText" rows="2" cols="35"></textarea>
<br/>
<a HREF="javascript:responseAction(<?php //echo $article->idarticle;?>)">Confirm action</a>
<a style="float: right;" HREF="javascript:actionDlgHide()">Cancel</a>
</div>
*/ ?>
</div>